#ifndef __ARG_PARSER__H
#define __ARG_PARSER__H
#include <map>
#include <set>
#include <string>
#include "types.h"

class ArgParser {
public:
	typedef std::set<std::string>::const_iterator FileIter;
	typedef std::map<std::string, bool>::const_iterator BoolIter;
	typedef std::map<std::string, std::string>::const_iterator StringIter;
	ArgParser(int argc, char *argv[]);
	FileIter GetFiles() const { return m_setFileArgs.begin(); }
	U32 GetFilesCount() const { return m_setFileArgs.size(); }
	
	bool IsTestRun() const { return IsSomething("test"); }
	bool IsNoHillClimbing() const { return IsSomething("no_hc"); }
	bool IsInternalRun() const { return IsSomething("internal"); }
	bool IsNoKeepAngleInRange() const { return IsSomething("no_keep_angle"); } 
	bool IsNoHorizonChecks() const { return IsSomething("no_horizon_checks"); }
	
	const char *GetOutputFilename() const { return GetSomethingString("out"); }
	const char *GetOrderOutputFileName() const { return GetSomethingString("order_out"); }
	const char *GetWindowTitle() const { return GetSomethingString("title"); }
	
	S32 GetMainVeinColor() const { return GetSomethingS32("main", -1); }
	S32 GetChildVeinColor() const { return GetSomethingS32("child", -1); }
	S32 GetChildVeinOppColor() const { return GetSomethingS32("child_opp", -1); }
	S32 GetJunctionColor() const { return GetSomethingS32("junction", -1); }
	S32 GetJunction90Color() const { return GetSomethingS32("junction_90", -1); }
	S32 GetJunctionOppColor() const { return GetSomethingS32("junction_opp", -1); }
	S32 GetJunction90OppColor() const { return GetSomethingS32("junction_90_opp", -1); }
	S32 GetForcedMainVeinIndex() const { return GetSomethingS32("forced_main_index", 0); }
	S32 GetForcedMainVeinCol() const { return GetSomethingS32("forced_main_col", -1); }
	S32 GetForcedMainVeinRow() const { return GetSomethingS32("forced_main_row", -1); }
	
private:
	void ParseBoolArgs(int argc, char *argv[]);
	void ParseFileArgs(int argc, char *argv[]);
	void ParseStringArgs(int argc, char *argv[]);
	bool IsSomething(const char *sz) const;
	const char *GetSomethingString(const char *sz) const;
	S32 GetSomethingS32(const char *sz, S32 nDefault) const;
private:
	std::map<std::string, bool> m_mapBoolArgs;
	std::map<std::string, std::string> m_mapStringArgs;
	std::set<std::string> m_setFileArgs;
};
#endif
